package server;

import java.util.Scanner;
import java.util.Timer;

public class Server {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		if (args.length < 1) {
			System.out.println("Error, No paramters");
			return;
		}
		
		int port = 0;
		try {
			port = Integer.parseInt(args[0]);
		} catch (NumberFormatException e) {
			System.out.println("Error, invalid port number");
			return;
		}
		
		ClientAccepterThread cat = new ClientAccepterThread(port);
		Thread t = new Thread(cat);
		t.start();
		System.out.println("Listening for clients, press Enter to exit...");
		
		Timer timer = new Timer();
		timer.schedule(new ExpireAuctionsTask(), 1000, 1000);
		
		Scanner sc = new Scanner(System.in);
		
		sc.nextLine();
		System.out.println("Exit");
		t.interrupt();
	}
}
